Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: don't cork noop .end() #36633

Closed
wants to merge 2 commits into from
Closed

Conversation

ronag
Copy link
Member

@ronag ronag commented Dec 26, 2020

Calling .end() a second time should be a noop and not
leave the socket corked.

Fixes: #36620

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Dec 26, 2020
@ronag
Copy link
Member Author

ronag commented Dec 26, 2020

@nodejs/http

@ronag ronag added v14.x and removed v14.x labels Dec 26, 2020
@ronag
Copy link
Member Author

ronag commented Dec 26, 2020

@kachkaev would you mind confirming whether this resolves your issue?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test for the 'drain' event as mentioned in the issue?

lib/_http_outgoing.js Show resolved Hide resolved
@kachkaev
Copy link

@ronag many thanks for the PR! I’m happy to try it out, I just don’t have any experience using custom Node builds. Do you know if it’s possible to do something like this in GitHub workflows? That would be the easiest and show the results transparently to everyone.

      - name: Use Node.js (custom build)
        uses: actions/setup-node@v2
        with:
          node-version: ?? from this PR ??

@ronag
Copy link
Member Author

ronag commented Dec 26, 2020

@kachkaev Sorry, I'm not familiar enough with that.

@mcollina
Copy link
Member

Do you know if it’s possible to do something like this in GitHub workflows?

Unfortunately no, we don't publish the builds from individual PRs.

@ronag
Copy link
Member Author

ronag commented Dec 26, 2020

Could you add a test for the 'drain' event as mentioned in the issue?

The bug is not that the drain event is missing. It's that the socket stays corked and doesn't write.

@mcollina
Copy link
Member

The bug is not that the drain event is missing. It's that the socket stays corked and doesn't write.

Then add a test for the write :). I would like to have a test that checks the end-user behavior.

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the test matteo asked for

@ronag
Copy link
Member Author

ronag commented Dec 27, 2020

Might need a separate backport for v14.

@mitsos1os
Copy link
Contributor

Hi, is there any progress with PR?

@ronag
Copy link
Member Author

ronag commented Jan 8, 2021

It's missing a test.

@ronag
Copy link
Member Author

ronag commented Jan 9, 2021

The bug is not that the drain event is missing. It's that the socket stays corked and doesn't write.

Then add a test for the write :). I would like to have a test that checks the end-user behavior.

If someone wants to help with writing this test I think we could merge this sooner rather than later.

@mitsos1os
Copy link
Contributor

The bug is not that the drain event is missing. It's that the socket stays corked and doesn't write.

Then add a test for the write :). I would like to have a test that checks the end-user behavior.

If someone wants to help with writing this test I think we could merge this sooner rather than later.

How would you like to help with the test? Could I submit to your repo?

@ronag
Copy link
Member Author

ronag commented Jan 9, 2021

How would you like to help with the test? Could I submit to your repo?

Just do your own fork, checkout a copy of this branch, and I can pull in your commit.

@mcollina
Copy link
Member

Conservatively putting it as semver-major.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ronag
Copy link
Member Author

ronag commented Jan 11, 2021

@mcollina i disagree with semver major. This is a fix for a rather serious bug. 🤔

@nodejs-github-bot
Copy link
Collaborator

@kachkaev
Copy link

kachkaev commented Jan 11, 2021

@mcollina I agree with @ronag on that this is a bug in v14 & v15. The behaviour unexpectedly changed between v13 and v14 according to my MWE: https://github.com/kachkaev/node-http-response-double-end-call-breaking-drain-event/runs/1606418629

It took me more than two working days in investigate the problem and create #36633 (it involved quite a few layers of abstraction to shave off). I wish others no longer fall into the same trap after upgrading to Node 14 from v12. Calling res.end() twice in Node < v14.0.0 was not punished or warned about.

@mcollina mcollina removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 11, 2021
@mcollina
Copy link
Member

Agreed, thanks for context.

@danielleadams
Copy link
Member

danielleadams commented Jan 12, 2021

@ronag do you mind consolidating bb17da1 and 085bb3a - I'm getting an issue landing the second commit since it is merged into this PR without a commit message.

ronag and others added 2 commits January 12, 2021 10:58
Calling .end() a second time should be a noop and not
leave the socket corked.

Fixes: nodejs#36620
ronag added a commit that referenced this pull request Jan 12, 2021
Calling .end() a second time should be a noop and not
leave the socket corked.

Fixes: #36620

PR-URL: #36633
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
ronag pushed a commit that referenced this pull request Jan 12, 2021
PR-URL: #36633
Fixes: #36620
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
@ronag
Copy link
Member Author

ronag commented Jan 12, 2021

Landed in 2af43f6...ec794f9

@ronag ronag closed this Jan 12, 2021
danielleadams pushed a commit that referenced this pull request Jan 12, 2021
Calling .end() a second time should be a noop and not
leave the socket corked.

Fixes: #36620

PR-URL: #36633
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 12, 2021
PR-URL: #36633
Fixes: #36620
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
@danielleadams danielleadams mentioned this pull request Jan 12, 2021
mitsos1os added a commit to mitsos1os/node that referenced this pull request Jan 15, 2021
PR-URL: nodejs#36633
Fixes: nodejs#36620
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
(cherry picked from commit ec794f9)
@mitsos1os
Copy link
Contributor

I have also issued the backport PR for v14 branch here: #36940

BethGriggs pushed a commit that referenced this pull request Jan 26, 2021
PR-URL: #36633
Backport-PR-URL: #36940
Fixes: #36620
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
BethGriggs pushed a commit that referenced this pull request Jan 26, 2021
PR-URL: #36633
Backport-PR-URL: #36940
Fixes: #36620
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Jan 26, 2021
BethGriggs pushed a commit that referenced this pull request Jan 28, 2021
PR-URL: #36633
Backport-PR-URL: #36940
Fixes: #36620
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
BethGriggs pushed a commit that referenced this pull request Jan 28, 2021
PR-URL: #36633
Backport-PR-URL: #36940
Fixes: #36620
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling res.end() twice stalls follow-up HTTP request (drain event is missing)
9 participants